﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gnosis.Alexandria.Model
{
    public abstract class NamedHashedCodedBase
        : NamedHashedBase, ICoded
    {
        private string _code = string.Empty;

        protected override void InitializeField(string fieldName, object value)
        {
            if (fieldName == "Code")
                _code = (string)value ?? string.Empty;
            else base.InitializeField(fieldName, value);
        }

        #region ICoded Members

        public string Code
        {
            get { return _code; }
            set
            {
                if (_code != value)
                {
                    _code = value;
                    AddChange("Code", value);
                }
            }
        }

        #endregion
    }
}
